/*
 * @Author: wang_changtan 2196064304@qq.com
 * @Date: 2024-02-21 01:30:22
 * @LastEditors: wang_changtan 2196064304@qq.com
 * @LastEditTime: 2024-02-23 20:41:00
 * @FilePath: /web_music_app_vue3_vite_ts/src/store/modules/global.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { defineStore } from "pinia";
import {musicArr} from "./data"


export default defineStore('global',{
    state:()=>{
        return {
            themeName: "default",//衣服
            backLeft:[],// 左后退
            backRight:[],// 右后退
            currentPath: '/home',//当前路由
            music_Arr:[
                ...musicArr
            ],// 音乐播发列表
        }
    },
    actions: {
        // 更新属性
        updateStateByKey(key: string, value: any) {
            const $this: any = this;
            $this[key] = value;
        },
        updateStateByKeys(objectKeys: object) {
            if(objectKeys){
                for (const key in objectKeys) {
                    if (Object.prototype.hasOwnProperty.call(objectKeys, key)) {
                        const v = objectKeys[key];
                        this.updateStateByKey(key, v);
                    }
                }
            }
        }

    }
})